
<%@ page import="com.walkingfiles.registry.Document" %>
<!doctype html>
<html>
	<head>
		<meta name="layout" content="main">
		<g:set var="entityName" value="${message(code: 'document.label', default: 'Document')}" />
		<title><g:message code="default.list.label" args="[entityName]" /></title>
	</head>
	<body>
	<div id="outer">
		<g:render template="/layouts/menu"/>
		<a href="#list-document" class="skip" tabindex="-1"><g:message code="default.link.skip.label" default="Skip to content&hellip;"/></a>
			<g:form method="get" action="list">
				<fieldset class="form">
					<g:render template="search"/>
				</fieldset>
				<fieldset class="buttons" style="text-align: right;">
					<g:submitButton name="${message(code: 'default.search.label', default: 'Search')}"/>
				</fieldset>
			</g:form>
		<div id="list-document" class="content scaffold-list" role="main">
			<h1><g:message code="default.list.label" args="[entityName]" /></h1>
			<g:if test="${flash.message}">
			<div class="message" role="status">${flash.message}</div>
			</g:if>
			<g:if test="${!documentInstanceList}">
			<p><g:message code="document.list.no.documents" default="No documents found"/></p>
			</g:if>
			<g:else>
			<table class="wf">
				<thead>
					<tr>
						<g:sortableColumn property="number" title="${message(code: 'document.number.label', default: 'Number')}"/>

						<g:sortableColumn property="subject.name" title="${message(code: 'document.subject.label', default: 'Subject')}" />

						<g:sortableColumn property="area.name" title="${message(code: 'document.currentArea.label', default: 'Area')}" />
							
						<th><g:message code="document.outbox.label" default="Outbox" /></th>
					</tr>
				</thead>
				<tbody>
				<g:each in="${documentInstanceList}" status="i" var="documentInstance">
					<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
					
						<td><g:link action="show" id="${documentInstance.id}">${fieldValue(bean: documentInstance, field: "number")}</g:link></td>
					
						<td>${fieldValue(bean: documentInstance, field: "subject.name")}</td>

						<td>${fieldValue(bean: documentInstance, field: "currentArea.name")}</td>

						<td><div id="outboxDiv${documentInstance.id}">
							<g:remoteLink action="${documentInstance.outbox ? 'removeFromOutbox' : 'addToOutbox'}" id="${documentInstance.id}" update="outboxDiv${documentInstance.id}" >
								<g:if test="${documentInstance.outbox}">
									<g:message code="document.outbox.action.remove" default="Remove"/>
								</g:if>
								<g:else>
									<g:message code="document.outbox.action.add" default="Add"/>
								</g:else>
							</g:remoteLink>
						</div></td>
					
					</tr>
				</g:each>
				</tbody>
			</table>
			<div class="pagination">
				<g:paginate total="${documentInstanceTotal}" />
			</div>
			</g:else>
		</div>
	</div>
	</body>
</html>
